package com.servlet.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.servlet.entity.User;
import com.servlet.service.UserService;

@WebServlet("/updateUser.do")
public class UpdateUser extends HttpServlet {
	private static final long serialVersionUID = 1L;
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		Integer id=Integer.parseInt(request.getParameter("id"));
		String name=request.getParameter("name");
		String age=request.getParameter("age");
		String addrs=request.getParameter("addrs");
		User user=new User();
		user.setId(id);
		user.setName(name);
		user.setAge(age);
		user.setAddrs(addrs);
		UserService userService=new UserService();
		userService.update(user);
		response.sendRedirect("listUser.do");
	}

}
